package Java1_228.Java_promotion_136_228.Java190_198__接口;

//定义计算机接口
public interface Calculator {
    public abstract int sum(int a, int b);
}

//计算器实现类
class CalculatorImpl implements Calculator {
    public int sum(int a, int b) {
        int result = a + b;
        return result;
    }
}

class calc {
    public static void main(String[] args) {
        Calculator calculator = new CalculatorImpl();
        calc(calculator);
    }

    //参数是接口类型  计算器接口
    public static void calc(Calculator calculator) {
        int result = calculator.sum(10, 20);
        System.out.println("结果是：" + result);
    }
}